'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.hasAndUpdate = undefined;

var _has = require('lodash/has');

var _has2 = _interopRequireDefault(_has);

var _set = require('lodash/set');

var _set2 = _interopRequireDefault(_set);

var _get = require('lodash/get');

var _get2 = _interopRequireDefault(_get);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var hasAndUpdate = exports.hasAndUpdate = function hasAndUpdate(obj, keyPath) {
    var updater = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (val) {
        return val;
    };

    if ((0, _has2.default)(obj, keyPath)) {
        (0, _set2.default)(obj, keyPath, updater((0, _get2.default)(obj, keyPath)));
    }
};

exports.default = hasAndUpdate;